package view;

import android.content.Context;
import android.content.res.Resources;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;

public class LevelImageAdapter extends BaseAdapter {
	private Context _mContext;

	// references to our images
	private Integer[] _pictures;
	private Integer[] _visibles;

	public LevelImageAdapter(Context c, Integer[] pictures, Integer[] visibles) {
		_mContext = c;
		this._pictures = pictures;
		this._visibles = visibles;
	}

	public int getCount() {
		return _pictures.length;
	}

	public Object getItem(int position) {
		return null;
	}

	public long getItemId(int position) {
		return 0;
	}

	// create a new ImageView for each item referenced by the Adapter
	public View getView(int position, View convertView, ViewGroup parent) {
		ImageView imageView;
		if (convertView == null) {
			imageView = new ImageView(_mContext);
			Resources r = parent.getResources();
			int pixel = (int) TypedValue.applyDimension(
					TypedValue.COMPLEX_UNIT_DIP, 55, r.getDisplayMetrics());
			imageView.setLayoutParams(new GridView.LayoutParams(pixel, pixel));
			imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
			imageView.setPadding(1, 1, 1, 1);
		} else {
			imageView = (ImageView) convertView;
		}
		imageView.setImageResource(_visibles[position]);
		imageView.setImageResource(_pictures[position]);
		return imageView;
	}

}